import React,{useState} from 'react'
import {View,StyleSheet,Button,PermissionsAndroid} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import Login from './pages/login';
import Home from './pages/home';
import SelectData from './pages/selectData';
import Clause from './pages/clause';
import {DefaultLoading} from './components/loading/useLoading';
import {DefaultToast} from './components/toast/useToast';
import {DefaultModal} from './components/useModal';
import Auth from './pages/auth';
import AddAssets from './pages/addAssets';
import SendAssets from './pages/sendAssets';
import DecodeSuccess from './pages/decodeSuccess';
import LoanSuccess from './pages/LoanSuccess';
import Result from './pages/result';
import FSDemo from './pages/fsDemo';
import Table from './pages/table';

const Stack = createNativeStackNavigator()

const Root = ()=>{


    return  (
        <NavigationContainer>
            <Stack.Navigator
                initialRouteName={'Login'}
                screenOptions={({navigation,route}) => ({
                    headerTintColor:"#333",
                    headerTransparent:true,
                    // headerLeft: (props)=>{
                    //     return props.canGoBack && (
                    //         <HeaderBackButton
                    //             onPress={() => navigation.goBack()} {...props} tintColor={'#333'}
                    //             backImage={({tintColor}) => {
                    //                 return <Image source={Images.back}
                    //                               resizeMode={'contain'}
                    //                               style={{width:screen.PIXEL_40,height:screen.PIXEL_40}}/>
                    //             }}/>);
                    // } ,
                    headerTitleAlign:'center',
                    headerBackButtonMenuEnabled:false,
                    // headerBackVisible:false,
                    // headerBackTitleVisible:false,
                    // headerBackImageSource:Images.back,
                    animation:'slide_from_right'
                })}
            >
                <Stack.Screen name={"Login"} component={Login} options={{headerTitle:''}} />
                <Stack.Screen name={"Home"} component={Home} options={{headerTitle:''}} />
                <Stack.Screen name={"SelectData"} component={SelectData} options={{headerTitle:'个人信用贷款'}} />
                <Stack.Screen name={"Clause"} component={Clause} options={{headerTitle:'个人信用贷款'}} />
                <Stack.Screen name={"Result"} component={Result} options={{headerTitle:''}} />
                <Stack.Screen name={"Auth"} component={Auth} options={{headerTitle:'鉴证'}} />
                <Stack.Screen name={"AddAssets"} component={AddAssets} options={{headerTitle:'导入个人数字资产'}} />
                <Stack.Screen name={"SendAssets"} component={SendAssets} options={{headerTitle:'接收数字资产'}} />
                <Stack.Screen name={"DecodeSuccess"} component={DecodeSuccess} options={{headerTitle:''}} />
                <Stack.Screen name={"LoanSuccess"} component={LoanSuccess} options={{headerTitle:'个人信用贷款'}} />
                <Stack.Screen name={"FSDemo"} component={FSDemo} options={{headerTitle:'RNFS-demo'}} />
                <Stack.Screen name={"Table"} component={Table} options={{headerTitle:''}} />

            </Stack.Navigator>

        </NavigationContainer>

    )
}
const App = ()=>{

    return (
        <DefaultLoading>
            <DefaultToast>
                <DefaultModal>
                    <Root/>
                </DefaultModal>
            </DefaultToast>
        </DefaultLoading>
    )
}
export default App

const styles = StyleSheet.create({
    container:{
        flex:1, backgroundColor:'#fff', justifyContent:'center',alignItems:'center'
    }
})
